
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
            <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
            <script type="text/html" id="LAY-good-list-table-img">
	            <img src="{{d.image}}" alt="" style="width:82px; height: 110px;">
	        </script>
	        <script type="text/html" id="LAY-good-list-table-stock">
	           <span class="sp1">{{d.total_stock}}</span>
               <a class="sp2" lay-event="tips1">?</a>
	        </script>
            <!--<script type="text/html" id="test-table-operate-barDemo">
                <a class="layui-btn layui-btn-xs" lay-event="edit">查看商品</a>
            </script>-->
            </div>
        </div>
        </div>
    </div>
    </div>
<script>
layui.use(['admin', 'table', 'form', 'upload'], function(){
    var table = layui.table
    ,form = layui.form
    ,admin = layui.admin
    ,upload = layui.upload
    ,view = layui.view
    ,element = layui.element
    ,$ = layui.$
	,cols = [
		[
			{
				align: 'center',
				width: 110,
				templet: '#LAY-good-list-table-img',
				title: '封面',
				field: 'image'
			}, {
				align: 'center',
				field: 'title',
				title: '书名'
			}, {
				align: 'center',
				field: 'author',
				title: '作者'
			}, {
				align: 'center',
				field: 'isbn',
				title: 'ISBN'
			}, {
				align: 'center',
				field: 'category_pid_title',
				title: '所属一级分类'
			}, {
				align: 'center',
				field: 'total_stock',
				title: '库存',
				templet: '#LAY-good-list-table-stock'
			}, {
				align: 'center',
				field: 'remind_users_count',
				title: '订阅到货提醒人数',
				sort: true
			}
//			, {
//				align: 'center',
//				fixed: 'right',
//				title: '操作',
//				toolbar: '#test-table-operate-barDemo'
//			}
		]
	];
	table.set({
		headers: { //通过 request 头传递
			'access-token': layui.data('layuiAdmin').access_token
		}
	});
	table.render({
		elem: '#test-table-operate',
		url: 'https://bookshop.dingdangtoy.com/api/admin/book/remind_books',
		parseData: function(res) { //res 即为原始返回的数据
			return {
				"code": res.code, //解析接口状态
				"msg": res.message, //解析提示文本
				"data": res.data.items, //解析数据列表
				"count": res.data._meta.total_count //解析数据长度

			}
		},
		cols: cols,
		page: true
	});

    //监听工具条
    table.on('tool(test-table-operate)', function(obj){
      var data = obj.data;
      if(obj.event === 'tips1'){
        admin.popup({
        title: '编辑名家'
        ,area: ['400px', '350px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('arrival/all/add', data).done(function(){
            form.render(null, 'layuiadmin-app-form-tags2');

          });
        }
      });
      }
    });


  });
</script>
  <style type="text/css">
  	.layui-table-cell, .layui-table-tool-panel li{white-space: inherit !important;}
  	.sp1{float: left;}
  	.sp2{float: left;width: 16px;margin-top: 5px;height: 16px;text-align: center;line-height: 16px;font-size: 14px;color: #ccc;border: 1px solid #ccc;border-radius: 50%;margin-left: 15px;cursor: pointer;}
  </style>
